/*
 * Copyright 2018-present KunMinX
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.nsgf.library.ui.adapter;

import android.content.Context;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.DiffUtil;
import androidx.recyclerview.widget.RecyclerView;

import com.kunminx.binding_recyclerview.adapter.SimpleDataBindingAdapter;
import com.nsgf.library.R;
import com.nsgf.library.data.bean.ClockInBean;
import com.nsgf.library.data.bean.WareHouseBean;
import com.nsgf.library.databinding.ItemNsgfHomeWareHouseBinding;
import com.nsgf.library.utils.UnitTo;

/**
 * Create by GC at 24/10/19
 */
public class WareHouseListAdapter extends SimpleDataBindingAdapter<WareHouseBean, ItemNsgfHomeWareHouseBinding> {

    public WareHouseListAdapter(Context context) {
        super(context, R.layout.item_nsgf_home_ware_house, new DiffUtil.ItemCallback<WareHouseBean>() {
            @Override
            public boolean areItemsTheSame(@NonNull WareHouseBean oldItem, @NonNull WareHouseBean newItem) {
                return false;
            }

            @Override
            public boolean areContentsTheSame(@NonNull WareHouseBean oldItem, @NonNull WareHouseBean newItem) {
                return false;
            }
        });

    }

    @Override
    protected void onBindItem(ItemNsgfHomeWareHouseBinding binding, WareHouseBean item, RecyclerView.ViewHolder holder) {

        binding.setVm(item);

        if ("store.level.1".equals(item.getStoreLevel())) {
            binding.ivItemTitleUp.setImageResource(R.drawable.ic_nsgf_house_item_street);
            UnitTo.setBorder(mContext, R.color.color_A0D1F6, R.color.color_E5F5FF, R.color.color_A0D1F6, binding.tvItemNsgfWareHouseLevel, 4);
        } else if ("store.level.2".equals(item.getStoreLevel())) {
            binding.ivItemTitleUp.setImageResource(R.drawable.ic_nsgf_house_item_area);
            UnitTo.setBorder(mContext, R.color.color_82A7FC, R.color.color_E1EAFF, R.color.color_82A7FC, binding.tvItemNsgfWareHouseLevel, 4);
        } else {
            binding.ivItemTitleUp.setImageResource(R.drawable.ic_nsgf_house_item_reservoir);
            UnitTo.setBorder(mContext, R.color.color_42DC64, R.color.color_E4FFEA, R.color.color_42DC64, binding.tvItemNsgfWareHouseLevel, 4);
        }
    }

}
